package game.game.ia.transition;

import java.util.List;

import astar.AStar;
import astar.IAstarMap;

import entity.Position;
import entity.object.EnemyEntity;
import game.engine.ia.ICleverEntity;
import game.engine.ia.IState;
import game.game.GameModel;
import game.game.ia.IGameIAModel;

public class TransitionFighting extends GameIATransition
{
	protected boolean _in;

	public TransitionFighting(IGameIAModel pModel, IState pNextState, boolean pIn)
	{
		super( pModel, pNextState );
		_in = pIn;
	}

	@Override
	public boolean isValidTransition( ICleverEntity pEntity )
	{
		GameModel model = (GameModel) _model;
		EnemyEntity entity = (EnemyEntity) pEntity;
		//
		List<Position> positionPath = new AStar( (IAstarMap) model.getMap() ).searchPath( pEntity.getTarget().getPosition() , entity.getPosition() );

		// List<ObjEntity> objInVision = new
		// VisionManager().getObjEntityInVision( model , entity , 0 );
		// return objInVision.isEmpty() == _in;
		return positionPath.size() <= 2 == _in;
	}

}
